<?php 
include("conexao.php");

$id = $_GET["id"];



$consulta = "select * from vendedor where id_loja='$id'";
$result   = mysql_query($consulta, $conexao);

$linha  = mysql_fetch_object($result);


if($linha == null){
	
	$query = "delete from loja where id_loja=".$id;
	$res   = mysql_query($query, $conexao);
	
	if($res){
		echo "
		<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cad_loja.php'>
		<script type=\"text/javascript\">
		alert(\"Loja deletada com sucesso.\");
		</script>
		";
	}
	
	else{
		echo "
		<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cad_loja.php'>
		<script type=\"text/javascript\">
		alert(\"Erro ao deletar Loja.\");
		</script>
		";
	}
	
}else{
	
	echo "
		<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cad_loja.php'>
		<script type=\"text/javascript\">
		alert(\"Existe vendedores nessa Loja.\");
		</script>
		";
	
	
}







?>